package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.Position;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Docker;
import com.ruoyi.system.service.IDockerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 医生Controller
 * 
 * @author ruoyi
 * @date 2024-02-26
 */
@RestController
@DataSource(DataSourceType.HOSDOCKER)
@RequestMapping("/system/docker")
public class DockerController extends BaseController
{
    @Autowired
    private IDockerService dockerService;

    /**
     * 查询医生列表
     */
    @PreAuthorize("@ss.hasPermi('system:docker:list')")
    @GetMapping("/list")
    public TableDataInfo list(Docker docker)
    {
        startPage();
        List<Docker> list = dockerService.selectDockerList(docker);
        return getDataTable(list);
    }

    /**
     * 导出医生列表
     */
    @PreAuthorize("@ss.hasPermi('system:docker:export')")
    @Log(title = "医生", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Docker docker)
    {
        List<Docker> list = dockerService.selectDockerList(docker);
        ExcelUtil<Docker> util = new ExcelUtil<Docker>(Docker.class);
        util.exportExcel(response, list, "医生数据");
    }

    /**
     * 获取医生详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:docker:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dockerService.selectDockerById(id));
    }

    /**
     * 新增医生
     */
    @PreAuthorize("@ss.hasPermi('system:docker:add')")
    @Log(title = "医生", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Docker docker)
    {
        docker.setDel(0L);
        return toAjax(dockerService.insertDocker(docker));
    }

    /**
     * 修改医生
     */
    @PreAuthorize("@ss.hasPermi('system:docker:edit')")
    @Log(title = "医生", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Docker docker)
    {
        return toAjax(dockerService.updateDocker(docker));
    }

    /**
     * 删除医生
     */
    @PreAuthorize("@ss.hasPermi('system:docker:remove')")
    @Log(title = "医生", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dockerService.deleteDockerByIds(ids));
    }

    /**
     * 查询全部医生
     */
    @GetMapping("/selectAll")
    public TableDataInfo selectList()
    {
        List<Docker> list = dockerService.selectAll();
        return getDataTable(list);
    }
}
